OPDATA-7692 filter endpoints by env var initial commit#804
OPDATA-7692 filter endpoints by env var initial commit#804mmcallister-cll wants to merge 5 commits into
Conversation
NPM Publishing labels 🏷️🟢 This PR has valid version labels and will cause a |
| const makeEndpoint = (name: string) => new AdapterEndpoint({ name, transport: new NopTransport() }) | ||
|
|
||
| test.afterEach(() => { | ||
| delete process.env['ENABLED_ENDPOINTS'] |
There was a problem hiding this comment.
Cleanup should go in beforeEach. If a test fails to clean up, you want that to fail, not some random next test.
This is more of an issue with jest where you can have before/afterEach apply to subsets of tests, but still a good rule of thumb to follow.
afterEach is only for assertions like "no errors happened during the test", or for cleanups that are not allowed to run initially.
| * Filters the adapter's endpoints based on the ENABLED_ENDPOINTS setting. | ||
| * If ENABLED_ENDPOINTS is not set, all endpoints are loaded. | ||
| * If ENABLED_ENDPOINTS is set, only the specified endpoints are loaded. | ||
| * Throws an error if none of the specified endpoints match. |
There was a problem hiding this comment.
I think it should throw if any of the listed endpoints don't match. That would be a mistake that you want to find out sooner rather than later.
| endpoints: [makeEndpoint('price'), makeEndpoint('volume')], | ||
| }) | ||
| t.is(adapter.endpoints.length, 1) | ||
| t.is(adapter.endpoints[0].name, 'price') |
There was a problem hiding this comment.
Combine these 2 lines into
t.deepEqual(adapter.endpoints.map(e => e.name), ['price'])
The error will be more useful than just the length not matching.
| name: 'TEST', | ||
| endpoints: [makeEndpoint('price'), makeEndpoint('volume')], | ||
| }) | ||
| t.is(adapter.endpoints.length, 2) |
https://smartcontract-it.atlassian.net/browse/OPDATA-7692